#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
using namespace std;

 class Solution1 {
 public:
     int removeDuplicates(vector<int>& nums) {
         int len = 1;
         vector<int>::iterator slow = nums.begin();
         vector<int>::iterator fast = nums.begin() + 1;
         while(fast != nums.end())
         {
             if(*slow == *fast)
             {
                 ++fast;
             }
             else
             {
                 len++;
                 ++slow;
                 *slow = *fast;
                 ++fast;
             }
         }
         return len;
     }
 };

class Solution2 {
public:
    int removeDuplicates(vector<int>& nums) {
        int slow = 0, fast = 1;
        while (fast < nums.size())
        {
            if (nums[slow] == nums[fast])
            {
                fast++;
            }
            else
            {
                slow++;
                nums[slow] = nums[fast++];
            }
        }
        return slow + 1;
    }
};